<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form @searchHandler='searchHandler' :more='true'>
        <f-search-form-item label='标题' name='designerTitle' />
      </f-search-form>
      <f-table ref='table' rowKey='designerId' :columns='columns' :multiple='true' :operator='operator' :params='queryParam' :api='api.spd'>
        <span slot='action' slot-scope='text, record'>
          <template>
            <a @click='$refs.drawer.showDrawer(record)'>编辑</a>
            <a-divider type='vertical' />
            <a @click='$refs.printDesigner.openModal(record)'>设计</a>
            <a-divider type='vertical' />
          </template>
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item v-if="$auth('table.delete')">
                <a href='javascript:;' @click='$refs.table.del(record)'>删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </f-table>
      <spd-drawer ref='drawer'></spd-drawer>
      <flyme-print-designer ref='printDesigner'></flyme-print-designer>
    </a-card>
  </div>
</template>
<script>
import spdDrawer from "./spd_drawer.vue"
import api from "./js/api"
import FlymePrintDesigner from "@/components/Flyme/FlymePrintDesigner"

export default {
  name: "TableList",
  components: {
    FlymePrintDesigner,
    spdDrawer
  },
  data() {
    let me = this
    //操作按钮
    let operator = []
    operator.push({
      name: "添加",
      icon: "plus",
      that: this,
      handler: (table, that) => {
        this.$refs.drawer.showDrawer()
      }
    })
    operator.push({
      name: "删除",
      icon: "delete",
      batch: true,
      handler: function(table) {
        table.remove()
      }
    })
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: "序号",
          width: "60",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "模板编码",
          align: "center",
          dataIndex: "designerCode"
        },
        {
          title: "模板标题",
          align: "center",
          dataIndex: "designerTitle"
        },
        {
          title: "创建时间",
          align: "center",
          dataIndex: "createTime"
        },
        {
          title: "操作",
          align: "center",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {}
}
</script>
